package com.skyline.attraction.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.skyline.attraction.model.AttractionInvitation;
import com.skyline.base.type.Activity;

public class AttractionInvitationMapper implements RowMapper<AttractionInvitation> {

	private final static String COLUMN_ID = "id";
	private final static String COLUMN_OWER_ID = "owerId";
	private final static String COLUMN_FAN_ID = "fanId";
	private final static String COLUMN_FAN_NICKNAME ="fanNickname";
	private final static String COLUMN_FAN_PORTRAIT = "fanPortait";
	private final static String COLUMN_SPOT_ID = "spotId";
	private final static String COLUMN_SPOT_NAME = "spotName";
	private final static String COLUMN_CONTENT = "content";
	private final static String COLUMN_INVITING_TIME = "invitingTime";
	private final static String COLUMN_APPOINTMENT_TIME = "appointmentTime";
	private final static String COLUMN_ACTIVITY = "activity";
	
	private final static AttractionInvitationMapper MAPPER = new AttractionInvitationMapper();
	
	
	public static AttractionInvitationMapper getMapper(){
		return MAPPER;
	}
	
	
	
	@Override
	public AttractionInvitation mapRow(ResultSet rs, int rowNum) throws SQLException {
		AttractionInvitation in = new AttractionInvitation();
		
		try {
			in.setId(rs.getLong(COLUMN_ID));
			in.setOwerId(rs.getLong(COLUMN_OWER_ID));
			in.setFanId(rs.getLong(COLUMN_FAN_ID));
			in.setFanNickname(rs.getString(COLUMN_FAN_NICKNAME));
			in.setFanPortait(rs.getString(COLUMN_FAN_PORTRAIT));
			in.setSpotId(rs.getLong(COLUMN_SPOT_ID));
			in.setSpotName(rs.getString(COLUMN_SPOT_NAME));
			in.setContent(rs.getString(COLUMN_CONTENT));
			in.setInvitingTime(rs.getDate(COLUMN_INVITING_TIME));
			in.setAppointmentTime(rs.getDate(COLUMN_APPOINTMENT_TIME));
			in.setActivity(Activity.valueOf(rs.getString(COLUMN_ACTIVITY)));
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return in;
	}

}
